#include <iostream>
#include <stdio.h>
#include <stdlib.h> 

using namespace std;

int lookup(int *arr,int arrlen,int key){
	int start = 0;
	int end = arrlen-1;
	// 求中位数 
	while(end-start>1){
		int mid = (end+start)/2;
		int midnum = arr[mid];
		if (key>midnum){
			start = mid;
		}else if (key<midnum){
			end = mid;
		}else {
			return mid+1;
		}
	}
	//当 start 和 end 相邻时 
	if (end-start==1){
		if (arr[start]==key){
			return start+1;
		}
		if (arr[end]==key){
			return end+1;
		}
		return -1;
	}
} 

int main(){
	int arr[] = {11,22,33,44,55,66,77,88,99,100};
	int a = 0;
	while(1){
		printf("input:");
		scanf("%d",&a);
		int i = lookup(arr,10,a);
		if (i==-1)
			printf("没找到诶！\n");
		else 
			printf("找到了，在第%d位\n",i);
	}
	return 0;	
} 